package com.aistar.mapper;

import com.aistar.model.entity.ResumeView;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName: ResumeViewMapper
 * @author: LiuWenXiu
 * @date: 2021/10/6 16:20
 * @Description: TODO...本类用来演示:
 */
public interface ResumeViewMapper {

    // 插入简历预览数据
    @Insert("insert into resume_view(resume_id,employer_id,company_id,company_name,view_time,count) values(#{resumeId},#{employerId},#{companyId},#{companyName},#{viewTime},1)")
    Integer insertResumeView(ResumeView resumeView);


    @Select("select * from resume_view")
    List<ResumeView> loadAll();

    @Select("select *from resume_view where resume_id = #{resumeId}")
    List<ResumeView> findById(Integer resumeId);

    // 根据简历id和公司id查询简历查看记录 -> 这个记录至多一条
    @Select("select * from resume_view where resume_id = #{resumeId} and company_id = #{companyId}")
    ResumeView findByResumeIdAndCompanyId(@Param("resumeId") Integer resumeId,@Param("companyId") Integer companyId);

    // 更新简历查看信息[查看时间,查看次数]
    @Update("update resume_view set count = #{count},view_time = #{viewTime} where id = #{id}")
    Integer updateResumeView(ResumeView resumeView);

    // 根据id获取简历查看记录
    @Select("select * from resume_view where id = #{id}")
    ResumeView getById(Integer id);

}
